@extends('departmentManagement.finance.layouts')
@section('style')
    <meta name="_token" content="{{ csrf_token() }}"/>
    <style>
        .finance-th {
            text-align: center;
            color: #676767;
        }

        .finance-td {
            text-align: center;
            color: #676767;
        }

        .ico_img {
            width: 80px;
            height: 80px;
            margin-top: -20px;
        }
    </style>
    <link rel="stylesheet" href="{{asset('admin_assets/css/bootstrap-datetimepicker.min.css')}}">
    <link rel="stylesheet" href="{{url('css/search.css')}}">
@stop
@section('content')
    <div class="content-wrapper" style="background-color: white">
        <section id="list" class="content">
            <div class="row">
                <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                    <div class="box box-info"
                         style="padding-top: 0px;margin-top: 0px;border-top: 0px;border-bottom: solid 1px #0080ff;">
                        <div class="box-body" style="">
                            <div class="row">
                                <div class="col-lg-2 col-md-2 col-sm-12 col-xs-12" style="margin-top: 0.5vw">
                                    <a href="#" title="返回首页" style="float: left"><i class="fa fa-home fa-2x"
                                                                                    style="width: 100%;color: #0080FF">
                                        </i></a>
                                    <a href="{{url('management/finance/index')}}"><span
                                                style="font-size: 18px;float: left;margin-top: 5px">&nbsp;首页</span></a>
                                    <div class="clear"></div>
                                </div>
                                <div class="col-lg-2 col-md-2 col-sm-12 col-xs-12  col-lg-offset-8 col-md-offset-8">
                                    {{--<form action="{{url('management/finance/indexSearch')}}" method="post" enctype="multipart/form-data" class="search">--}}
                                        {{--{{csrf_field()}}--}}
                                        {{--<button class="fa fa-search fa-lg"></button>--}}
                                        {{--<input class="search" value="keywords" type="search" id="search-input" name="search">--}}
                                    {{--</form>--}}
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-lg-3 col-xs-6">
                    <div class="small-box bg-aqua">
                        <div class="inner">
                            <h3>{{$count[0]}}</h3>
                            <p>待结算</p>
                        </div>
                        <div class="icon">
                            <img class="ico_img" src="{{asset('admin_assets/img/dealing_money_icon.png')}}">
                        </div>
                    </div>
                </div>
                <div class="col-lg-3 col-xs-6">
                    <div class="small-box bg-green">
                        <div class="inner">
                            <h3>{{$count[1]}}</h3>
                            <p>已结算</p>
                        </div>
                        <div class="icon">
                            <img class="ico_img" src="{{asset('admin_assets/img/finish_money_icon.png')}}">
                        </div>
                    </div>
                </div>
                <div class="col-lg-3 col-xs-6">
                    <div class="small-box bg-yellow">
                        <div class="inner">
                            <h3>{{$count[2]}}</h3>
                            <p>已收款额</p>
                        </div>
                        <div class="icon">
                            <img class="ico_img" src="{{asset('admin_assets/img/end_money_icon.png')}}">
                        </div>
                    </div>
                </div>
                <div class="col-lg-3 col-xs-6">
                    <div class="small-box bg-red">
                        <div class="inner">
                            <h3>{{$count[3]}}</h3>
                            <p>款项总额</p>
                        </div>
                        <div class="icon">
                            <img class="ico_img" src="{{asset('admin_assets/img/money_total_icon.png')}}">
                        </div>
                    </div>
                </div>
            </div>
            @include('public/alert')
            <div class="row">
                <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                    <div class="table-responsive">
                        <table class="table table-bordered">
                            <thead>
                            <tr>
                                <th class="finance-th">编号</th>
                                <th class="finance-th">公司</th>
                                <th class="finance-th">任务类别</th>
                                <th class="finance-th">类型</th>
                                <th class="finance-th">名称</th>
                                <th class="finance-th">申请人</th>
                                <th class="finance-th">处理人</th>
                                <th class="finance-th">申请日期</th>
                                <th class="finance-th">款项金额</th>
                                <th class="finance-th">尾款金额</th>
                                <th class="finance-th">尾款支付时间</th>
                                <th class="finance-th">操作</th>
                            </tr>
                            </thead>
                            <tbody class="list">
                            @if($product->isNotEmpty())
                                @foreach($product as $k =>$v)
                                    @php($item=$v['Product'])
                                    <tr>
                                        <td class="finance-td">
                                            {{$k+1}}
                                            @if(($v['finance_state']+1)!=$config['finish'])
                                                @if($v['tail']==1)
                                                    <small class="label pull-right bg-red">尾</small>
                                                @endif
                                                @if($v['first']==1)
                                                    <small class="label pull-right bg-red">首</small>
                                                @endif
                                            @endif
                                        </td>
                                        <td class="finance-td company">{{$item['company']}}</td>
                                        <td class="finance-td is_renew">
                                            @if($v['is_renew']==0)
                                                首次任务
                                            @else
                                                续费任务
                                            @endif
                                        </td>
                                        <td class="finance-td firstType">{{$v['FirstType']['name']}}</td>
                                        <td class="finance-td name">{{$item['name']}}</td>
                                        <td class="finance-td applicant">{{$item['applicant']}}</td>
                                        <td class="finance-td agent">{{$v['agent']}}</td>
                                        <td class="finance-td created_at">{{$item['created_at']}}</td>
                                        <td class="finance-td price">
                                            @if(empty($item['price']))
                                                未设置款项
                                            @else
                                                ¥{{$item['price']}}
                                            @endif
                                        </td>
                                        <td class="finance-td tail_payment">
                                            @if(empty($item['tail_payment']))
                                                未设置尾款
                                            @else
                                                ¥{{$item['tail_payment']}}
                                            @endif
                                        </td>
                                        <td class="finance-td tail_pay_time">
                                            @if(empty($item['tail_pay_time']))
                                                未支付尾款
                                                @if($v['urge']==1)
                                                    <small class="label pull-right bg-red">催</small>
                                                @endif
                                            @else
                                                {{$item['tail_pay_time']}}
                                            @endif
                                        </td>
                                        <td class="finance-td finance_state">
                                            @if(($v['finance_state']+1)!=$config['finish'])
                                                <a href="{{url('management/finance/operation',['pid'=>$v['id'],'id'=>$item['id'],'state'=>$v['finance_state']])}}">{{$map[$v['finance_state']]}}</a>
                                            @else
                                                <span style="cursor: pointer">{{$map[$v['finance_state']]}}</span>
                                            @endif
                                        </td>
                                    </tr>
                                @endforeach
                            @else
                                <tr>
                                    <td class="finance-td" colspan="11"><h3 align="center">暂无数据</h3></td>
                                </tr>
                            @endif
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </section>
    </div>
@stop
@section('javascript')
    <script src="{{asset('js/list.min.js')}}"></script>
    <script>
        var options = {
            valueNames: ['is_renew','firstType','company','name','applicant','agent','created_at','price','tail_payment','tail_pay_time','finance_state']
        };
        var List = new List('list', options);
        List.search($('#search-input').val());
    </script>
@stop
